#region Copyright RenGuiYou. All rights reserved.
//=====================================================
// NeatlyFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================
#endregion
using System.Collections.Generic;
using Pandora;
using PandoraEditor;
using UnityEditor;
using UnityEngine;

namespace NeatlyEditor
{
    public static class AssetBundleExport
    {
        public static AssetBundleManifest ExportAssetBundle(Dictionary<string, List<string>> buildMap)
        {
            AssetBundleBuild[] bundleBuildArray = new AssetBundleBuild[buildMap.Count];
            int i = 0;
            foreach (var kv in buildMap)
            {
                bundleBuildArray[i].assetBundleName = kv.Key;
                bundleBuildArray[i].assetNames = kv.Value.ToArray();
                i++;
            }
            PdrFileUtil.CreateDirectory(NeatlyEditorConfig.PATH_TEMP_BUNDLE);
            var options = BuildAssetBundleOptions.ChunkBasedCompression;
            if (NeatlyEditorConfig.BUILD_TARGET == BuildTarget.WebGL)
            {
                options |= BuildAssetBundleOptions.DisableWriteTypeTree;
            }
            return BuildPipeline.BuildAssetBundles(NeatlyEditorConfig.PATH_TEMP_BUNDLE, bundleBuildArray, options, NeatlyEditorConfig.BUILD_TARGET);
        }
    }
}